Skip to content

feat(pr-reviewer): read the repo's AGENTS.md and guideline docs before reviewing - #474

Merged
enyst merged 4 commits into
OpenHands:mainfrom
smolpaws:feat/reviewer-read-agents-md
Aug 27, 2026
Merged

feat(pr-reviewer): read the repo's AGENTS.md and guideline docs before reviewing#474
enyst merged 4 commits into
OpenHands:mainfrom
smolpaws:feat/reviewer-read-agents-md

Conversation

@smolpaws

@smolpaws smolpaws commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

HUMAN:
This PR proposes to nudge the reviewer agent to read the contribution guidelines in the repo under review, e.g. AGENTS.md including nested, if any, or other common .md files.

  • A human has tested these changes.

Why

Current main now gives the automation an exact PR checkout as its workspace and can inject one configured review-guide file. That covers the preferred custom guide when it exists, but it does not replace discovery of root and nested AGENTS.md files or other repository guidance such as CONTRIBUTING.md.

The /codereview plugin prompt likewise did not explicitly tell the reviewer to inspect repository-owned guidance. Both review surfaces should make that discovery step explicit so project rules consistently influence automated reviews.

Summary

  • Tell the cron automation reviewer to read the repository's root AGENTS.md, any nested AGENTS.md covering changed files, and other relevant contribution/review docs before inspecting the PR.
  • Preserve current main's managed-workspace and direct GitHub-review flow; the reviewer no longer clones, checks out, or deletes the repository itself.
  • Add the same guidance requirement to the /codereview plugin prompt.
  • Cover both prompt surfaces with focused tests.
  • Regenerate the automation bundle after the merged prompt change.

Issue Number

Fixes #519

How to Test

  • uv run --group test pytest -q tests/ - 780 passed, 14 skipped.
  • uv run pytest -q skills/github-pr-reviewer/tests/test_main.py - 52 passed.
  • uv run python scripts/sync_extensions.py --check - passed; reports the existing non-blocking issue-duplicate-checker marketplace warning.
  • uv run python scripts/sync_openhands_sdk_skill.py --check - up to date.
  • npm run build:automations and npm run build:skills - regenerated checked-in artifacts.
  • git diff --check - clean.

Video/Screenshots

N/A - prompt/guidance change with no UI surface.

Notes

After updating from main, CI's live SDK-doc sync also detected the newly published 58_ask_oracle_tool example. The prescribed generator refreshed skills/openhands-sdk/SKILL.md and skills/index.js; no SDK documentation was edited by hand.

…e reviewing

The PR reviewer did not reliably see a repository's own guidance. The
cron automation clones the target repo into a workspace subdirectory, so its
AGENTS.md is never loaded into the agent's context as an always-on repo skill;
the reviewer had no instruction to read it either.

Tell both reviewer prompt surfaces — the automation's _build_review_prompt and
the /codereview plugin prompt — that they MUST read the repository's AGENTS.md
(root + any nested one covering the changed files) plus other relevant docs
(CONTRIBUTING.md, CLAUDE.md, .cursorrules, review/coding guidelines) and apply
that guidance. This lets a repo steer reviews via AGENTS.md, matching how it
steers working agents.

Co-authored-by: smolpaws <engel@enyst.org>
@enyst
enyst marked this pull request as ready for review August 27, 2026 01:50
@enyst
enyst requested a review from all-hands-bot August 27, 2026 01:50

all-hands-bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Taste Rating: 🟡 Acceptable — works, but introduces two overlapping mechanisms for the same goal.

Summary

This PR adds an instruction in both reviewer prompts (plugins/pr-review/scripts/prompt.py:81 and skills/github-pr-reviewer/scripts/main.py:811) telling the spawned reviewer agent to autonomously read AGENTS.md (and other guideline docs) before reviewing. Existing tests are extended with substring assertions.

What works

  • The prompt wording is clear and consistent across the two prompts that needed updating.
  • The must read semantics are intentionally strong, which is the right call given how often AI reviewers otherwise skip repo conventions.
  • The test additions are appropriate for prompt-template changes (asserting key substrings on the rendered string).
  • No new external dependencies; no security or breaking-change risk; pure prompt-string edit.

Concerns (minor — not blocking)

  1. Duplicate prose across two files (the inline comments flag both spots). The "MUST read AGENTS.md..." paragraph is now duplicated verbatim between prompt.py and main.py. If the list of files ever changes (SECURITY.md, STYLE.md, etc.), both files have to be updated in lockstep — and the test substring list will silently drift out of sync. Consider extracting one shared constant (e.g. REPO_GUIDANCE_INSTRUCTION) and concatenating it into both prompts.

  2. Overlaps with the existing REPO_REVIEW_GUIDE_PATH mechanism in skills/github-pr-reviewer/scripts/main.py (_load_repo_review_guide, lines ~752 and the guide_section injection). That mechanism already deterministically reads .agents/skills/custom-codereview-guide.md and injects its contents into the prompt. This PR adds a second, non-deterministic overlay that asks the spawned agent to do similar discovery on its own. The two paths have overlapping but not identical scope. A cleaner design would be to extend the host script (the deterministic path) to also walk the changed-file paths and inject any matching AGENTS.md (root + nested) as a single <repository_guidance> block — eliminating the runtime cost, the latency, and the non-determinism of asking the agent to do the discovery.

  3. Hardcoded step numbering churn in main.py — inserting a new "step 2" required renumbering every subsequent step (1→2 ... 8→9). The cross-reference to the fallback (fallback in step 5) was updated to step 6, so it's currently consistent, but the underlying smell is that the prompt has hardcoded numbers that have to be hand-maintained on every reorder. If a step is ever inserted or removed again, a number will silently disagree.

These are suggestions for a follow-up; they don't block merging this PR.

Testing

  • test_prompt_requires_reading_repository_guidance and test_prompt_instructs_reading_repo_guidance assert on substring presence in the rendered prompt. Appropriate for prompt-template changes; not behavioral coverage.
  • The previous behaviour (guide section injection, _load_repo_review_guide paths) is unchanged and previously tested.

Risk & Safety

  • 🟢 LOW. Prompt-only change in a non-production-critical path. Worst case: a reviewer conversation spends a few extra tool calls reading AGENTS.md, or follows a stale guideline and produces a slightly different review. No data loss, no security regression, no user-visible product change.

Verdict

✅ Worth merging. The behaviour described in the title works as advertised. The duplication and overlap-with-existing-mechanism concerns are worth a follow-up but don't justify holding this PR.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

Comment thread plugins/pr-review/scripts/prompt.py
Comment thread skills/github-pr-reviewer/scripts/main.py
Comment thread skills/github-pr-reviewer/scripts/main.py Outdated

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Taste Rating: 🟡 Acceptable — works, but introduces two overlapping mechanisms for the same goal.

Summary

This PR adds an instruction in both reviewer prompts (plugins/pr-review/scripts/prompt.py:81 and skills/github-pr-reviewer/scripts/main.py:811) telling the spawned reviewer agent to autonomously read AGENTS.md (and other guideline docs) before reviewing. Existing tests are extended with substring assertions.

What works

  • The prompt wording is clear and consistent across the two prompts that needed updating.
  • The must read semantics are intentionally strong, which is the right call given how often AI reviewers otherwise skip repo conventions.
  • The test additions are appropriate for prompt-template changes (asserting key substrings on the rendered string).
  • No new external dependencies; no security or breaking-change risk; pure prompt-string edit.

Concerns (minor — not blocking)

  1. Duplicate prose across two files (the inline comments flag both spots). The "MUST read AGENTS.md..." paragraph is now duplicated verbatim between prompt.py and main.py. If the list of files ever changes (SECURITY.md, STYLE.md, etc.), both files have to be updated in lockstep — and the test substring list will silently drift out of sync. Consider extracting one shared constant (e.g. REPO_GUIDANCE_INSTRUCTION) and concatenating it into both prompts.

  2. Overlaps with the existing REPO_REVIEW_GUIDE_PATH mechanism in skills/github-pr-reviewer/scripts/main.py (_load_repo_review_guide, lines ~752 and the guide_section injection). That mechanism already deterministically reads .agents/skills/custom-codereview-guide.md and injects its contents into the prompt. This PR adds a second, non-deterministic overlay that asks the spawned agent to do similar discovery on its own. The two paths have overlapping but not identical scope. A cleaner design would be to extend the host script (the deterministic path) to also walk the changed-file paths and inject any matching AGENTS.md (root + nested) as a single <repository_guidance> block — eliminating the runtime cost, the latency, and the non-determinism of asking the agent to do the discovery.

  3. Hardcoded step numbering churn in main.py — inserting a new "step 2" required renumbering every subsequent step (1→2 ... 8→9). The cross-reference to the fallback (fallback in step 5) was updated to step 6, so it's currently consistent, but the underlying smell is that the prompt has hardcoded numbers that have to be hand-maintained on every reorder. If a step is ever inserted or removed again, a number will silently disagree.

These are suggestions for a follow-up; they don't block merging this PR.

Testing

  • test_prompt_requires_reading_repository_guidance and test_prompt_instructs_reading_repo_guidance assert on substring presence in the rendered prompt. Appropriate for prompt-template changes; not behavioral coverage.
  • The previous behaviour (guide section injection, _load_repo_review_guide paths) is unchanged and previously tested.

Risk & Safety

  • 🟢 LOW. Prompt-only change in a non-production-critical path. Worst case: a reviewer conversation spends a few extra tool calls reading AGENTS.md, or follows a stale guideline and produces a slightly different review. No data loss, no security regression, no user-visible product change.

Verdict

✅ Worth merging. The behaviour described in the title works as advertised. The duplication and overlap-with-existing-mechanism concerns are worth a follow-up but don't justify holding this PR.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline-comment debugging test.

@OpenHands OpenHands deleted a comment from all-hands-bot Aug 27, 2026
@OpenHands OpenHands deleted a comment from all-hands-bot Aug 27, 2026
@OpenHands OpenHands deleted a comment from all-hands-bot Aug 27, 2026
@OpenHands OpenHands deleted a comment from all-hands-bot Aug 27, 2026
@enyst
enyst merged commit 370ee2c into OpenHands:main Aug 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Make automated reviewers read repository guidance

3 participants